package com.hspedu.map_;

import java.util.Hashtable;

/**
 * @Author Stringzhua
 * @Date 2024/3/13 15:33
 * description:
 */
@SuppressWarnings("all")
public class HashTableExercise {
    public static void main(String[] args) {
        Hashtable table = new Hashtable();
        table.put("john", 100);
//        table.put(null,100);//java.lang.NullPointerException
//        table.put("john",null);//java.lang.NullPointerException
        table.put("lucy", 100);
        table.put("lic", 100);
        table.put("lic", 88);//替换
        table.put("hello1", 1);
        table.put("hello2", 1);
        table.put("hello3", 1);
        table.put("hello4", 1);
        table.put("hello5", 1);
        table.put("hello6", 1);
        System.out.println("table = " + table);

        /*
         * 简单分析Hashtable
         * 0.k-v都不能为空,否则抛出异常
          if (value == null) {
            throw new NullPointerException();
            }
         * 1.底层有一个数组 Hashtable$Entry[]  初始化大小为 11
         * 2.临界值 threshold 8 =11*0.75
         * 3.扩容:按照自己的扩容机制来进行即可
         * 4.执行 方法 addEntry(hash,key,value,index);添加K-V封装到Entry
         * 5.当if(count>=threshold) 满足时,就进行扩容
         * 6.按照int newCapacity = (oldCapacity << 1) + 1; 的大小扩容
         * */
    }
}
